<template>
    <view>
        <u-toast ref="uToast" /><u-no-network></u-no-network>
        <u-navbar title="设置" safeAreaInsetTop fixed placeholder>
            <view class="coreshop-navbar-left-slot" slot="left">
                <u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
                <u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
                <u-icon name="home" size="22" @click="goHome"></u-icon>
            </view>
            <view slot="right">
            </view>
        </u-navbar>
        <u-list>
            <u-list-item>
                <u-cell :title="`个人资料`" @click="navigateToHandle('/pages/member/setting/userInfo/index')">
                    <u-icon slot="icon" shape="square" size="18" randomBgColor name="setting"></u-icon>
                    <u-icon slot="right-icon" shape="square" size="18" randomBgColor name="arrow-right"></u-icon>
                </u-cell>
            </u-list-item>
            <!-- #ifdef APP-PLUS || APP-PLUS-NVUE -->
            <u-list-item>
                <u-cell title="修改密码" @click="navigateToHandle('/pages/member/setting/userInfo/password')">
                    <u-icon slot="icon" shape="square" size="18" randomBgColor name="warning"></u-icon>
                    <u-icon slot="right-icon" shape="square" size="18" randomBgColor name="arrow-right"></u-icon>
                </u-cell>
            </u-list-item>
            <!-- #endif -->
            <u-list-item>
                <u-cell title="关于我们" @click="goAboutUs()">
                    <u-icon slot="icon" shape="square" size="18" randomBgColor name="tags"></u-icon>
                    <u-icon slot="right-icon" shape="square" size="18" randomBgColor name="arrow-right"></u-icon>
                </u-cell>
            </u-list-item>
            <u-list-item>
                <u-cell title="用户协议" @click="goUserAgreementPage()">
                    <u-icon slot="icon" shape="square" size="18" randomBgColor name="order"></u-icon>
                    <u-icon slot="right-icon" shape="square" size="18" randomBgColor name="arrow-right"></u-icon>
                </u-cell>
            </u-list-item>
            <u-list-item>
                <u-cell title="隐私政策" @click="goUserPrivacyPolicy()">
                    <u-icon slot="icon" shape="square" size="18" randomBgColor name="eye-off"></u-icon>
                    <u-icon slot="right-icon" shape="square" size="18" randomBgColor name="arrow-right"></u-icon>
                </u-cell>
            </u-list-item>
            <!--<u-list-item>
                <u-cell title="清除缓存" @click="clearCache">
                    <u-icon slot="icon" shape="square" size="18" randomBgColor name="trash"></u-icon>
                    <u-icon slot="right-icon" shape="square" size="18" randomBgColor name="arrow-right"></u-icon>
                </u-cell>
            </u-list-item>-->
            <!-- #ifdef APP-PLUS || APP-PLUS-NVUE -->
            <u-list-item>
                <u-cell title="切换账号" @click="changeAccount">
                    <u-icon slot="icon" shape="square" size="18" randomBgColor name="account"></u-icon>
                    <u-icon slot="right-icon" shape="square" size="18" randomBgColor name="arrow-right"></u-icon>
                </u-cell>
            </u-list-item>
            <!-- #endif -->
        </u-list>
        <!-- #ifdef APP-PLUS || APP-PLUS-NVUE -->
        <view class="coreshop-bg-white coreshop-footer-fixed coreshop-foot-padding-bottom">
            <u-button class="coreshop-percent-100" type="error" size="normal" @click="logOff">退出登录</u-button>
        </view>
        <!-- #endif -->
    </view>
</template>

<script>

    export default {

        methods: {
            navigateToHandle(pageUrl) {
                this.$u.route(pageUrl)
            },
            //// 清除缓存
            //clearCache() {
            //    // 重新获取统一配置信息
            //    this.$u.api.shopConfigV2().then(res => {
            //        this.$store.commit('config', res.data)
            //    })
            //    //获取地区信息
            //    this.$u.api.getAreaList().then(res => {
            //        if (res.status) {
            //            // 删除地区缓存信息
            //            this.$db.del('areaList');
            //            this.$db.set('areaList', res.data)
            //        }
            //    });
            //    setTimeout(() => {
            //        this.$refs.uToast.show({ message: '清除成功', type: 'success' })
            //    }, 500)
            //},

            // 退出登录
            logOff() {
                var that = this;
                this.$common.modelShow('退出', '确认退出登录吗?', () => {
                    that.$store.commit('hasLogin', false);
                    that.$store.commit('userInfo', "");
                    that.$db.del('userToken')
                    uni.reLaunch({
                        url: '/pages/index/default/default'
                    })
                })
            },
            // 切换账号
            changeAccount() {
                var that = this;
                this.$common.modelShow('切换', '确认切换登录账号吗?', () => {
                    that.$db.del('userToken')
                    that.$u.route({ url: '/pages/login/loginBySMS/loginBySMS', });
                })
            }
        }
    }
</script>

<style lang="scss">
    page { background: #fff; }
</style>
